package fashionshop.bll;

import java.sql.ResultSet;
import java.util.Vector;

import fashionshop.dal.CategoryDAL;
import fashionshop.dal.ProductDAL;


public class CategoryBLL {
	
	private int id;
	private String name;
	private int active;

	public CategoryBLL() {
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getActive() {
		return active;
	}

	public void setActive(int active) {
		this.active = active;
	}
	
	
	
	public ResultSet LoadAllCategory() throws Exception{
		return CategoryDAL.LoadAll();
	}
	
	public ResultSet LoadCategoryByID(int id) throws Exception{
		
		return CategoryDAL.LoadByID(id);
	}
	
	public int Add() throws Exception{
		return CategoryDAL.Insert(this);
	}
	
	public int Edit() throws Exception{
		return CategoryDAL.Update(this);
	}
	
	public static ResultSet loadAllCategory() throws Exception {
		
//		Vector categoryTableRecords = new Vector();
//		ResultSet result = CategoryDAL.LoadAll();
//		while (result.next()){
//			Vector record = new Vector();
//            record.add(result.getInt("ID"));
//            record.add(result.getString("Name"));
//            record.add(result.getInt("Active"));
//			
//            categoryTableRecords.add(record);
//		}
//		return categoryTableRecords;
		return CategoryDAL.LoadAll();
	}
	
	public static int getIdFromName(String name) throws Exception {
		ResultSet result = CategoryDAL.LoadIDByName(name);
		int id = 0;
		while (result.next()){
			id = result.getInt("ID");
		}
		return id;
	}
}
